﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ChMetody_3
{
    class HalfDivision
    {
        public static double Method(string s, double a_, double b_, double e)
        {
            double a = a_;
            double b = b_;
            double c = (b + a) / 2;
            while (Math.Abs(b - a) > e & Functions.f(s, c)!=0)
            {
                if (Functions.f(s, a)*Functions.f(s, c)<0)
                    b=c;
                else 
                    a=c;
                c = (a + b) / 2;
            }
            return c;
        }
    }
}
